    var dataJson;

    /**
    *@Author cirly
    *@Description 初始页面调取商品信息并显示
    *@Date 12:24 2018/11/5
    *@Modify by
    *@Version 1.0
    */
    window.onload=function (){
       // var productQR = "test123";
        var data = "";
        //alert(data);
        // var xmlhttp = null;
        var url = "productInfo!productList";
        sendRequest("post", url, data, getProductBack);
    };

    /**
     *@Author cirly
     *@Description 接受返回json字符串 ，类型为Array
     *@Date 12:27 2018/11/5
     *@Modify by
     *@Version 1.0
     */
    function getProductBack(result){
        //alert(result);
        var rs =  eval('(' + result + ')');
        //sessionStorage.setItem("allProduct",rs);
        //console.log(rs);
        //var obj = new Function("return" + rs)();//不知道为啥要这一步，反正能转成对象就对了，求解答   ---cirly
        rs = JSON.parse(rs);
        dataJson = rs;
        indexData(dataJson);
       // alert(rs[0].productName);
    }



    function classifyProduct (type) {
        //console.log(type);
        var classfyJson = [];
        for (var i= 0;i<dataJson.length;i++){
            if(dataJson[i].productType == type) classfyJson.push(dataJson[i]);
        }
        if(classfyJson.length <= 0){
            alert("对不起，此类商品尚未上架！");
        }else{
            indexData(classfyJson);
        }

    }

    /**
     *@Author cirly
     *@Description 显示主页商品信息。（分页暂未加入）
     *@Date 12:27 2018/11/5
     *@Modify by
     *@Version 1.0
     */
    function indexData(dataJson){
        var str="";
        var salePrice;
        for(var i = 0 ; i < dataJson.length ; i++){

            //var imgAddr = [] ;
           // imgAddr = dataJson[i].proproductPhotoFileAddr.splitText(",");
        //var str="";
        /*str+=' <a href="javascript:void(0)" id=\"' + dataJson[i].productQR + '\" onclick="transfer(this)" class="aui-ware-grid-item" xmlns="http://www.w3.org/1999/html"><div class="aui-ware-grid-img"> <img src='
            data:image/jpg;base64,'+ dataJson[i].proproductPhotoFileAddr+' alt=""></div><div class="aui-ware-grid-mes"><h3>'
            +dataJson[i].productName+'</h3> <br class="aui-ware-grid-mes-item"><div class="aui-ware-grid-price"><span><i>￥</i>'
            +dataJson[i].salePrice+'</span>\n'
            +'</div></br>' +'<div class="aui-ware-grid-time">2010年-9.7万公里</div></br>'
            +'</div></br>' + '</div></br>' +'</a>';*/
        str += "<a href=\"javascript:void(0)\" id=  "+dataJson[i].productQR+"  onclick=\"transfer(this)\" class=\"aui-ware-grid-item\" xmlns=\"http://www.w3.org/1999/html\">\n" +
            "    \t\t<div class=\"aui-ware-grid-img\"> \n" +
            "    \t\t\t<img src=\"data:image/jpg;base64,"+ dataJson[i].productPhoto+"\" alt=\"\" style=\"width: 50px;height: 30px;\" width=\"30px;\ ">\n" +
            "    \t\t</div>\n" +
            "    \t\t<div class=\"aui-ware-grid-mes\">\n" +
            "    \t\t\t<h3>"+dataJson[i].productName+"</h3> \n" +
            "    \t\t\t<br class=\"aui-ware-grid-mes-item\">\n" +
            "    \t\t\t\t<div class=\"aui-ware-grid-price\">\n" +
            "    \t\t\t\t\t<span><i>售价：￥"+ dataJson[i].salePrice +"</i></span>" +
            "</br><span><i>租价：￥"+ dataJson[i].rentPrice +" /天</i>"+
            "    \t\t\t\t\t</span>\n" +
            "    \t\t\t\t</div></br>\n" +
            "    \t\t\t\t<div class=\"aui-ware-grid-time\">"+ dataJson[i].introduction +"</div>\n" +
            "    \t\t\t\t</br>\n" +
            "            </div></br>\n" +
            "            </div></br>\n" +
            "    \t</a>"
            //style='text-decoration: line-through'
            if(dataJson[i].salePrice == 0){

            }else{

            }

            if(dataJson[i].rentPrice == 0){
                salePrice = "该商品不可租";
            }else{
                salePrice = dataJson[i].rentPrice;
            }
        }
        document.getElementById("productList").innerHTML = str;

    }

    /**
     *@Author cirly
     *@Description 跳转到详情页面
     *@Date 12:50 2018/11/5
     *@Modify by
     *@Version 1.0
     */
    function transfer(a) {
        var productQR = a.id;
        if(productQR != null){
            var data = "productQR=" + productQR;
            //var proCode = encodeURI(data);

            window.location.href = "item.html?" + data;
        }
        //alert(productQR);
        //此法行不通
        /*if(productQR != null) {
            //sessionStorage.setItem("productQR", productQR);
            var url = "productInfo!getById";
            var data = "productQR=" + productQR;
            sendRequest("post",url,data,showItem);
            //window.location.href = "item.html";
        }else{
            alert("商品信息获取失败，请稍后再试！");
        }*/
    }

    /*function showItem(result) {
        var productInfoStr = eval("("+ result +")");
        var data = "productInfo=" + productInfoStr;
        //alert(productInfoStr);
        alert(encodeURI(productInfoStr));
        //console.log(encodeURIComponent(productInfoStr));
        window.location.href = "item.html?" + data;
    }*/

    /**
     *@Author cirly
     *@Description 根据类型对全体产品进行分类
     *@Date 20:10 2018/11/5
     *@Modify by
     *@Version 1.0
     */
    function productClassfy(data , type ){
        var returnData ={};
        for(var i = 0; i<data.length; i++){
            if(data[i].productType == type) returnData.push(data[i]);
        }
        return returnData;
    }
